package io.gitee.xyuesheng.day06;

import org.junit.Test;

import java.util.*;

public class HomeworkRandom {
    @Test
    public void testMap() {
        Map<Integer, String> map = new HashMap<>();
        map.put(1, "1");
        map.put(2, "2");
        map.put(3, "3");
        map.put(4, "4");
        map.put(5, "5");
        map.put(6, "6");
        map.put(7, "7");
        map.put(8, "8");
        map.put(9, "9");
        map.put(10, "10");

        while (!map.isEmpty()) {
            int i = (int) (Math.random() * 10 + 1);
            if (map.containsKey(i)) {
                System.out.print("i:" + i + " ");
                System.out.println("key:" + i + " " + "value:" + map.get(i));
                map.remove(i);
            }
        }
    }


    @Test
    public void testSet() {
        Set<Integer> set = new HashSet<>();
        for (int i = 1; i <= 10; i++) {
            set.add(i);
        }
        System.out.println(set);
        System.out.println("###############################");

        while (!set.isEmpty()) {
            int i = (int) (Math.random() * 10 + 1);
            if (set.contains(i)) {
                set.remove(i);
                System.out.print("i:" + i + " ");
                System.out.println(set);
            }
        }
    }


}
